<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>webAudio demo1</title>
    <script>
        setFontSize()
        window.onresize = function () { setFontSize() }
        function setFontSize() { document.getElementsByTagName('html')[0].style.fontSize = parseInt(document.documentElement.clientWidth) / 7.5 + 'px' }
    </script>
    <style>
        html,
        body {
            margin: 0;
            overflow: hidden;
            font-family: sans-serif;
            background: #13091B;
            height: 100%;
        }

        body {
            background: url(https://p1.music.126.net/gAmIGjlWnYXE_0O8LFp5-w==/109951164382001054.jpg) no-repeat;
            background-size: cover;
        }

        #canvas {
            position: fixed;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
        }

        audio {
            // visibility: hidden;
        }

        #play-btn {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: #13091B;
            background: #007A99;
            display: block;
            width: 150px;
            height: 45px;
            line-height: 45px;
            font-size: 18px;
            cursor: pointer;
            border-radius: 4px;
            letter-spacing: 0.1em;
            z-index: 1;
            text-align: center;
            text-decoration: none;
        }
    </style>
</head>

<body>
    <div id="main">
        <div id="content">
            <canvas id="canvas"></canvas>
            <audio id="audio" controls
                src="//m8.music.126.net/21180815163607/04976f67866d4b4d11575ab418904467/ymusic/515a/5508/520b/f0cf47930abbbb0562c9ea61707c4c0b.mp3?infoId=92001"
                crossOrigin="anonymous"></audio>
            <a href="javascript:;" id="play-btn">PLAY</a>
        </div>
    </div>

    <script type="module">
        import onLoadAudio from './audio-analyser.js'
        var btn = document.getElementById("play-btn");
        var audio = document.getElementById("audio");

        btn.onclick = function () {
            btn.style.display = "none";

            audio.play();
            onLoadAudio(document.getElementById("canvas"), audio);
        };
    </script>
</body>

</html>
